package org.ljx.taobao.service;

import org.ljx.taobao.api.IUserService;
import org.ljx.taobao.api.entity.User;
import org.ljx.taobao.dao.IUserDao;
import org.ljx.taobao.dao.impl.UserDaoImpl;

import java.sql.SQLException;

/**
 * @Author: Ljx
 * @Date: 2021/12/31 12:36
 * @role: 用户service层实现
 */
public class UserServiceImpl implements IUserService {

    /**
     * 注册用户
     * @param user 用户实体
     * @return boolean
     * @throws SQLException sql语句异常
     */
    @Override
    public boolean insertUser(User user) throws SQLException {
        IUserDao iUserDao = new UserDaoImpl();
        return iUserDao.insertUser(user);
    }

    /**
     * 修改用户密码
     * @param user 用户实体
     * @return boolean
     * @throws ClassNotFoundException 文件异常
     */
    @Override
    public boolean change(User user) throws ClassNotFoundException {
        IUserDao iUserDao = new UserDaoImpl();
        return iUserDao.change(user);
    }

    /**
     * 用户登录
     * @param user 用户实体
     * @return boolean
     */
    @Override
    public boolean login(User user) {
        IUserDao iUserDao = new UserDaoImpl();
        return iUserDao.login(user);
    }

    /**
     * 删除用户
     * @param user 用户实体
     * @return boolean
     */
    @Override
    public boolean delete(User user) {
        IUserDao iUserDao = new UserDaoImpl();
        return iUserDao.delete(user);
    }

}
